<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="osgi,karaf,maven," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="说在前面基于J2EE的开发在企业应用中之所以如此普及，这是与J2EE定义了Web容器，开发者只需要关注核心业务实现是分不开的。例如，用户应用开发完成，只需放到Tomcat的Webapp中，启动Tomcat就可以运行查看业务效果。
同样的问题，在基于OSGi的开发中，为了简化系统的复杂性，我们在开发阶段通过模块化创建了大量的Bundle，如何让这些由不同人员开发，甚至是分散在不同团队开发的Bundl">
<meta property="og:type" content="article">
<meta property="og:title" content="Apache Karaf构建动态模块化应用(4)--了解Apache Karaf">
<meta property="og:url" content="http://chrisrc.me/2015/08/02/java-osgi-dynamic-app-with-karaf/index.html">
<meta property="og:site_name" content="山中，山外与俯瞰">
<meta property="og:description" content="说在前面基于J2EE的开发在企业应用中之所以如此普及，这是与J2EE定义了Web容器，开发者只需要关注核心业务实现是分不开的。例如，用户应用开发完成，只需放到Tomcat的Webapp中，启动Tomcat就可以运行查看业务效果。
同样的问题，在基于OSGi的开发中，为了简化系统的复杂性，我们在开发阶段通过模块化创建了大量的Bundle，如何让这些由不同人员开发，甚至是分散在不同团队开发的Bundl">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_karaf_framework.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_karaf_console.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_karaf_webconsole.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_karaf_logging.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_karaf_config_1.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_karaf_webapp.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_karaf_jpa.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_karaf_osgi_app.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_karaf_deploy_1.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_karaf_deploy_2.png">
<meta property="og:image" content="http://chrisrc.me/images/java_osgi_karaf_deploy_3.png">
<meta property="og:updated_time" content="2016-12-17T04:03:28.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Apache Karaf构建动态模块化应用(4)--了解Apache Karaf">
<meta name="twitter:description" content="说在前面基于J2EE的开发在企业应用中之所以如此普及，这是与J2EE定义了Web容器，开发者只需要关注核心业务实现是分不开的。例如，用户应用开发完成，只需放到Tomcat的Webapp中，启动Tomcat就可以运行查看业务效果。
同样的问题，在基于OSGi的开发中，为了简化系统的复杂性，我们在开发阶段通过模块化创建了大量的Bundle，如何让这些由不同人员开发，甚至是分散在不同团队开发的Bundl">
<meta name="twitter:image" content="http://chrisrc.me/images/java_osgi_karaf_framework.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://chrisrc.me/2015/08/02/java-osgi-dynamic-app-with-karaf/"/>





  <title> Apache Karaf构建动态模块化应用(4)--了解Apache Karaf | 山中，山外与俯瞰 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">山中，山外与俯瞰</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">一次永不停止的探索之旅</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-dcos">
          <a href="/dcos" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-book"></i> <br />
            
            DC/OS
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="st-search-show-outputs">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <form class="site-search-form">
  <input type="text" id="st-search-input" class="st-search-input st-default-search-input" />
</form>

<script type="text/javascript">
  (function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
    (w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
    e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
  })(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

  _st('install', 'R9GcmhBwxpsAGLNCsquZ','2.0.0');
</script>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://chrisrc.me/2015/08/02/java-osgi-dynamic-app-with-karaf/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="chrisrc">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="山中，山外与俯瞰">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="山中，山外与俯瞰" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                Apache Karaf构建动态模块化应用(4)--了解Apache Karaf
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2015-08-02T22:12:36+08:00">
                2015-08-02
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/OSGi/" itemprop="url" rel="index">
                    <span itemprop="name">OSGi</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <a href="/2015/08/02/java-osgi-dynamic-app-with-karaf/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2015/08/02/java-osgi-dynamic-app-with-karaf/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="说在前面"><a href="#说在前面" class="headerlink" title="说在前面"></a>说在前面</h2><p>基于J2EE的开发在企业应用中之所以如此普及，这是与J2EE定义了Web容器，开发者只需要关注核心业务实现是分不开的。例如，用户应用开发完成，<br>只需放到Tomcat的Webapp中，启动Tomcat就可以运行查看业务效果。</p>
<p>同样的问题，在基于OSGi的开发中，为了简化系统的复杂性，我们在开发阶段通过模块化创建了大量的Bundle，如何让这些由不同人员开发，<br>甚至是分散在不同团队开发的Bundle可以很容易的聚合在一起，测试，运行和打包发布？下面我们来看如何通过<a href="http://karaf.apache.org" target="_blank" rel="external">Apache Karaf</a>实现前述需求。</p>
<h2 id="Apache-Karaf"><a href="#Apache-Karaf" class="headerlink" title="Apache Karaf"></a>Apache Karaf</h2><p>通常，一个可部署的系统应该包括：<br>启动停止的控制脚本<br>运行系统所需的参数配置文件<br>可部署的业务构件<br>系统运行时的日志服务<br>系统运行时的监控服务<br>支持系统进行横向扩展的集群能力等</p>
<p>仍以Tomcat为例，可以看出Tomcat很好的提供了上述功能。</p>
<p>下述将简要罗列一下Karaf提供的基本功能特性。</p>
<h3 id="Karaf特性"><a href="#Karaf特性" class="headerlink" title="Karaf特性"></a>Karaf特性</h3><p>Apache Karaf为基于OSGi的应用在开发，运行调试，测试，部署和生产环境运维等各个环节提供了支持。<br>结合OSGi的动态特性，Karaf为基于OSGi Bundle构件提供了：<br>灵活的配置和部署<br>基于“Feature”的应用构建<br>轻量级模块化，按需供应<br>高级的日志服务<br>动态的参数配置<br>命令行管理与控制<br>远程管理<br>支持不同的OSGi框架<br>通过Feature提供大量的基础服务<br><img src="/images/java_osgi_karaf_framework.png" alt="Karaf Framework"></p>
<h3 id="Karaf目录结构"><a href="#Karaf目录结构" class="headerlink" title="Karaf目录结构"></a>Karaf目录结构</h3><pre><code>|
+---bin                   : Startup scripts and commands
+---data                 : Karaf work directory
      | +---cache         : Installed bundles
      | +---log           : Default log directory
      | +---tmp           : Temporary files
+---deploy               : Directory for file system deployment
+---etc                   : Configuration files
+---instances           : Instance management
+---lib                   : Core libraries
+---system               : System bundle repository
</code></pre><p><strong>etc</strong> 目录存放系统及业务Bundle的配置参数。</p>
<p><strong>system</strong> 目录存放的是遵循Maven仓库结构的Bundle仓库。</p>
<h3 id="Karaf环境变量"><a href="#Karaf环境变量" class="headerlink" title="Karaf环境变量"></a>Karaf环境变量</h3><table>
<thead>
<tr>
<th style="text-align:left">变量</th>
<th style="text-align:left">说明</th>
<th style="text-align:left">默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>KARAF_HOME|Karaf的安装路径|根据启动脚本的位置计算<br>KARAF_BASE|    Karaf的base路径|    KARAF_HOME<br>KARAF_DATA|    存储运行时数据的路径|    KARAF_BASE/data<br>KARAF_ETC|    配置文件的存储路径|    KARAF_BASE/etc<br>KARAF_OPTS|    传递给Java命令行参数|<br>KARAF_DEBUG|    如果值为‘true’，启动调试模式|  </p>
<h3 id="Karaf的控制台"><a href="#Karaf的控制台" class="headerlink" title="Karaf的控制台"></a>Karaf的控制台</h3><p><code>KARAF_HOME/bin/</code>目录下存放着Karaf的控制脚本，执行<code>karaf</code> 或者 <code>karaf.bat</code>启动Karaf服务框架:<br><img src="/images/java_osgi_karaf_console.png" alt="Karaf Console"></p>
<p>Karaf控制台提供了大量的命令，用户可以很容易的为自己的项目提供自定义命令（具体参考本系列中的 <strong>greeter-client</strong> 工程）。</p>
<ul>
<li>bundle:* - Install and control bundles</li>
<li>dev:* - Development support</li>
<li>feature:* - Manage features</li>
<li>instance:* - Control of multiple instances</li>
<li>jaas:* - JAAS role and rights management</li>
<li>log:* - log display</li>
<li>obr:* - Interaction with OSGi Bundle Repositories</li>
<li>scr:* - Declarative Services management</li>
<li>service:* - Manage OSGi Services</li>
<li>shell:* - useful helper functions (i.e. grep, more, java info)</li>
<li>ssh:* - SSH connections</li>
<li>system:* - OSGi framework management</li>
<li>web:* - WAR bundle management</li>
<li>wrapper:* - OS service installation</li>
</ul>
<h3 id="Karaf的Web控制台"><a href="#Karaf的Web控制台" class="headerlink" title="Karaf的Web控制台"></a>Karaf的Web控制台</h3><p>启动Karaf后，在命令行输入<code>feature install webconsole</code>， 然后访问：<a href="http://localhost:8080/system/console" target="_blank" rel="external">http://localhost:8080/system/console</a>  </p>
<p><img src="/images/java_osgi_karaf_webconsole.png" alt="Karaf WebConsole"></p>
<h3 id="Karaf远程管理"><a href="#Karaf远程管理" class="headerlink" title="Karaf远程管理"></a>Karaf远程管理</h3><p>Karaf启动时会启动一个SSHd Server，可以通过SSH远程访问Karaf。Karaf通过<code>KARAF_ETC/org.apache.karaf.shell.cfg</code>文件管理SSH服务相关的配置。详细<br>信息可参考<a href="http://karaf.apache.org/manual/latest/users-guide/remote.html" target="_blank" rel="external">Karaf文档</a></p>
<h3 id="Karaf-Logging日志服务"><a href="#Karaf-Logging日志服务" class="headerlink" title="Karaf Logging日志服务"></a>Karaf Logging日志服务</h3><p>Karaf 通过Pax Logging聚合了当前各个主流日志框架，通过<code>org.ops4j.pax.logging.cfg</code>可以对日志服务进行配置管理，通过命令行命令可以方便的<br>切换日志级别，查看日志输出。</p>
<p><img src="/images/java_osgi_karaf_logging.png" alt="Karaf WebConsole"></p>
<h3 id="Karaf配置服务"><a href="#Karaf配置服务" class="headerlink" title="Karaf配置服务"></a>Karaf配置服务</h3><p>Karaf的配置服务功能非常强大，用户可以为每个bundle进行独立配置。Karaf的bundle配置遵循OSGi <strong>Service Config Admin服务</strong>，<br>并通过<a href="http://felix.apache.org/documentation/subprojects/apache-felix-file-install.html" target="_blank" rel="external">Felix File Install</a>组件<br>实时监控KARAF_ETC目录，自动启用变更的配置。</p>
<p><img src="/images/java_osgi_karaf_config_1.png" alt="Karaf WebConsole"></p>
<h3 id="Karaf-Web-Application支持"><a href="#Karaf-Web-Application支持" class="headerlink" title="Karaf Web Application支持"></a>Karaf Web Application支持</h3><p>Karaf通过<a href="https://github.com/ops4j/org.ops4j.pax.web" target="_blank" rel="external">Pax Web</a>提供对Web应用的支持。通过标准的OSGi HTTP Service，可以将Web应用资源注册为OSGi服务。<br>此外，Pax Web支持直接部署War和Wab，并支持CDI。Pax Web 4.0.x特性如下：  </p>
<ul>
<li>Servlet 3.0</li>
<li>JSP 2.0</li>
<li>JSF 2.1</li>
<li>Jetty 9.0.x</li>
<li>Tomcat 7.x (still experimental, but better supported)</li>
<li>support of CDI (through Pax-CDI)</li>
<li>support of only Servlet 3.0 annotated Servlets in JAR</li>
<li>Web-Fragments</li>
</ul>
<p><img src="/images/java_osgi_karaf_webapp.png" alt="Karaf WebConsole"></p>
<h3 id="Karaf-Persistence服务"><a href="#Karaf-Persistence服务" class="headerlink" title="Karaf Persistence服务"></a>Karaf Persistence服务</h3><p>Karaf 通过<a href="http://aries.apache.org/modules/jpaproject.html" target="_blank" rel="external">Apache Aries JPA</a>为OSGi Bundle开发提供JPA支持。</p>
<p><img src="/images/java_osgi_karaf_jpa.png" alt="Karaf WebConsole"></p>
<h2 id="OSGi项目结构及Karaf的部署"><a href="#OSGi项目结构及Karaf的部署" class="headerlink" title="OSGi项目结构及Karaf的部署"></a>OSGi项目结构及Karaf的部署</h2><h3 id="OSGi项目结构"><a href="#OSGi项目结构" class="headerlink" title="OSGi项目结构"></a>OSGi项目结构</h3><p>通常，一个J2EE项目以OSGi模块化开发时，会根据项目的J2EE架构分层和业务模块进行粒度拆分。下面是一个典型的J2EE项目到OSGi项目的架构映射：</p>
<p><img src="/images/java_osgi_karaf_osgi_app.png" alt="Karaf WebConsole"><br>该项目来自：<a href="https://github.com/Cloudyle/petclinic" target="_blank" rel="external">https://github.com/Cloudyle/petclinic</a></p>
<h3 id="Karaf的项目部署"><a href="#Karaf的项目部署" class="headerlink" title="Karaf的项目部署"></a>Karaf的项目部署</h3><p>Karaf支持下列构件的部署：<br>Bundles<br>Blueprint files (xml)<br>Features<br>Kar Archives<br>“plain” jar files</p>
<p><img src="/images/java_osgi_karaf_deploy_1.png" alt="Karaf Deployment"></p>
<p>通常的部署模式基本可以支持产品项目的部署需求。根据项目的实际需要，也可以对Karaf进行裁剪以更适合产品的定制需求。<br>这种方式，可以将部署构件发布到<code>KARAF_HOME/system</code>下，将构件定义的Feature在<code>org.apache.karaf.features.cfg</code>中进行配置。</p>
<p><img src="/images/java_osgi_karaf_deploy_2.png" alt="Karaf Deployment"><br><img src="/images/java_osgi_karaf_deploy_3.png" alt="Karaf Deployment"></p>
<h3 id="greeter-osgi-example的部署"><a href="#greeter-osgi-example的部署" class="headerlink" title="greeter-osgi-example的部署"></a><a href="https://github.com/christtrc/greeter-osgi-example" target="_blank" rel="external">greeter-osgi-example</a>的部署</h3><ol>
<li>在<code>greeter-osgi-example</code>项目主目录下，通过控制台执行<code>mvn clean install</code></li>
<li><p>启动Karaf，在控制台通过下述命令安装 <strong>greeter-service</strong> Feature：  </p>
<blockquote>
<p>feature:repo-add mvn:org.example.greeter.feature/greeter-feature-service/1.0.0-SNAPSHOT/xml/features<br>feature:install scr greeter-service</p>
</blockquote>
</li>
<li><p>通过下述命令安装 <strong>greeter-client</strong> Feature：  </p>
<blockquote>
<p>feature:repo-add mvn:org.example.greeter.feature/greeter-feature-client/1.0.0-SNAPSHOT/xml/features<br>feature:install scr greeter-client</p>
</blockquote>
</li>
<li><p>通过下面的命令可以查看bundle是否正确安装，服务是否正确启动并测试：</p>
<blockquote>
<p>la  #查看bundle列表<br>service:list | grep -i greeter  #查找服务是否正确启动<br>greeter geeker  #测试服务</p>
</blockquote>
</li>
</ol>
<h2 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h2><ul>
<li>通过上述介绍我们可以看到Karaf为OSGi开发提供了丰富的功能支持。实际上，通过Feature机制，Karaf为Spring，为整个J2EE体系提供了开发支持。</li>
<li>此外，Karaf通过Cellar子项目提供了集群扩展能力，并且支持Cloud部署。</li>
<li>下一篇文章我们将介绍Karaf在集群中的部署及应用，后续文章将基于此项目展开IT自动化过程。</li>
</ul>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/osgi/" rel="tag"># osgi</a>
          
            <a href="/tags/karaf/" rel="tag"># karaf</a>
          
            <a href="/tags/maven/" rel="tag"># maven</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2015/07/31/java-osgi-dynamic-app-with-karaf-maven/" rel="next" title="Apache Karaf构建动态模块化应用(3)--使用Maven自动打包部署Bundle">
                <i class="fa fa-chevron-left"></i> Apache Karaf构建动态模块化应用(3)--使用Maven自动打包部署Bundle
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2015/08/03/java-osgi-dynamic-app-with-karaf-dev/" rel="prev" title="Apache Karaf构建动态模块化应用(5)--基于Maven快速搭建Karaf调试环境">
                Apache Karaf构建动态模块化应用(5)--基于Maven快速搭建Karaf调试环境 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2015/08/02/java-osgi-dynamic-app-with-karaf/"
     data-title="Apache Karaf构建动态模块化应用(4)--了解Apache Karaf"
     data-content=""
     data-url="http://chrisrc.me/2015/08/02/java-osgi-dynamic-app-with-karaf/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2015/08/02/java-osgi-dynamic-app-with-karaf/"
           data-title="Apache Karaf构建动态模块化应用(4)--了解Apache Karaf" data-url="http://chrisrc.me/2015/08/02/java-osgi-dynamic-app-with-karaf/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="chrisrc" />
          <p class="site-author-name" itemprop="name">chrisrc</p>
          <p class="site-description motion-element" itemprop="description"></p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">69</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">21</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">162</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/christtrc" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/chrisrc" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
          
        </div>

        
        
          <div class="cc-license motion-element" itemprop="license">
            <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
              <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons" />
            </a>
          </div>
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#说在前面"><span class="nav-number">1.</span> <span class="nav-text">说在前面</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Apache-Karaf"><span class="nav-number">2.</span> <span class="nav-text">Apache Karaf</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Karaf特性"><span class="nav-number">2.1.</span> <span class="nav-text">Karaf特性</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Karaf目录结构"><span class="nav-number">2.2.</span> <span class="nav-text">Karaf目录结构</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Karaf环境变量"><span class="nav-number">2.3.</span> <span class="nav-text">Karaf环境变量</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Karaf的控制台"><span class="nav-number">2.4.</span> <span class="nav-text">Karaf的控制台</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Karaf的Web控制台"><span class="nav-number">2.5.</span> <span class="nav-text">Karaf的Web控制台</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Karaf远程管理"><span class="nav-number">2.6.</span> <span class="nav-text">Karaf远程管理</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Karaf-Logging日志服务"><span class="nav-number">2.7.</span> <span class="nav-text">Karaf Logging日志服务</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Karaf配置服务"><span class="nav-number">2.8.</span> <span class="nav-text">Karaf配置服务</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Karaf-Web-Application支持"><span class="nav-number">2.9.</span> <span class="nav-text">Karaf Web Application支持</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Karaf-Persistence服务"><span class="nav-number">2.10.</span> <span class="nav-text">Karaf Persistence服务</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#OSGi项目结构及Karaf的部署"><span class="nav-number">3.</span> <span class="nav-text">OSGi项目结构及Karaf的部署</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#OSGi项目结构"><span class="nav-number">3.1.</span> <span class="nav-text">OSGi项目结构</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Karaf的项目部署"><span class="nav-number">3.2.</span> <span class="nav-text">Karaf的项目部署</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#greeter-osgi-example的部署"><span class="nav-number">3.3.</span> <span class="nav-text">greeter-osgi-example的部署</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#结论"><span class="nav-number">4.</span> <span class="nav-text">结论</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">
     
      <a href="mailto:chrisrc@qq.com">chrisrc</a> 
    
  </span>
  <span class="author"> &nbsp; QQ: 58122705 </span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"chrisrc"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  








  
  

  

  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  
<script>
(function(){
   var src = (document.location.protocol == "http:") ? "http://js.passport.qihucdn.com/11.0.1.js?ed903ab05fbc5fa64d95e4bfbf3d3a04":"https://jspassport.ssl.qhimg.com/11.0.1.js?ed903ab05fbc5fa64d95e4bfbf3d3a04";
   document.write('<script src="' + src + '" id="sozz"><\/script>');
})();
</script>

  


</body>
</html>
